//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.ft.adbix.core.widget;

import android.content.Context;
import android.hardware.SensorManager;
import android.util.AttributeSet;
import android.view.animation.LinearInterpolator;
import android.widget.LinearLayout;
import android.widget.Scroller;

import com.ft.adbix.utils.UIUtils;

public class GravityRotationView extends LinearLayout {
    private int a = -1;
    private int b = 0;
    private int c = 0;
    private int d = -1;
    private int e = -1;
    private Scroller f;

    public GravityRotationView(Context var1) {
        super(var1);
        this.a(var1, (AttributeSet)null, 0);
    }

    public GravityRotationView(Context var1, AttributeSet var2) {
        super(var1, var2);
        this.a(var1, var2, 0);
    }

    public GravityRotationView(Context var1, AttributeSet var2, int var3) {
        super(var1, var2, var3);
        this.a(var1, var2, var3);
    }

    private void a(Context var1, AttributeSet var2, int var3) {
        this.f = new Scroller(var1, new LinearInterpolator());
    }

    private void a(int var1, int var2) {
        this.f.startScroll(this.getScrollX(), this.getScrollY(), var1, var2, 80);
        this.invalidate();
    }

    private int a(int var1) {
        return UIUtils.dp2px(getContext(), var1);
    }

    public void computeScroll() {
        super.computeScroll();
        if (this.f.computeScrollOffset()) {
            this.scrollTo(this.f.getCurrX(), this.f.getCurrY());
            this.postInvalidate();
        }

    }

    public void a(Boolean var1) {
        if (var1) {
            this.a = 1;
        } else {
            this.a = -1;
        }

    }

    public void a(float[] var1, float[] var2) {
        float[] var3;
        float[] var10001 = var3 = new float[3];
        float[] var10009 = new float[9];
        SensorManager.getRotationMatrix(var10009, (float[])null, var1, var2);
        SensorManager.getOrientation(var10009, var3);
        var10001[0] = (float)Math.toDegrees((double)var10001[0]);
        var10001[1] = (float)Math.toDegrees((double)var10001[1]);
        var10001[2] = (float)Math.toDegrees((double)var10001[2]);
        int var7 = (int)var10001[1];
        int var8 = (int)var10001[2];
        if (this.d == -1 && this.e == -1) {
            this.d = var7;
            this.e = var8;
        }

        int var9 = Math.abs(var7 - this.b);
        int var4 = Math.abs(var8 - this.c);
        int var5 = this.f.getFinalX();
        int var6 = this.f.getFinalY();
        if (2 <= var4 && var4 < 40 || 2 <= var9 && var9 < 40) {
            if (-40 < var7 - (var9 = this.d) && var7 - var9 <= 0 || 1 <= var7 - (var9 = this.d) && var7 - var9 < 40) {
                var6 = (this.a == -1 ? this.a(5) : this.a(3)) * -this.a * (var7 - this.d) / 14;
            }

            if (-40 < var8 - (var9 = this.e) && var8 - var9 <= 0 || 1 <= var8 - (var9 = this.e) && var8 - var9 < 40) {
                var5 = this.a(17) * this.a * (var8 - this.e) / 40;
            }

            this.a(var5 - this.getScrollX(), var6 - this.getScrollY());
            this.b = var7;
            this.c = var8;
        }

    }

    public int getRotationAngleX() {
        return this.b;
    }

    public int getRotationAngleY() {
        return this.c;
    }

    public void setRotationAngleX(int var1) {
        this.b = var1;
    }

    public void setRotationAngleY(int var1) {
        this.c = var1;
    }
}
